/*
 * This file is part of connotea-java.
 *
 * connotea-java is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * connotea-java is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package org.connotea;

/**
 * Checked exception thrown when a Connotea API call could not be completed.
 * This exception will always be a wrapper for {@link Message}s returned by
 * Connotea. The only exception to this rule are
 * {@link Message#INVALID} and
 * {@link Message#NULL}, which are required as
 * client application generated {@link Message}s for fail-safe purposes.
 * 
 * @author <a href="mailto:christopher.townson@googlemail.com">Christopher
 *         Townson</a>
 */
public class ConnoteaException extends Exception {

    private Message apiMessage;

    private static final long serialVersionUID = 1L;

    /**
     * @param message the error
     */
    public ConnoteaException(Message message) {
        super(message.getMessage());
        apiMessage = message;
    }

    /**
     * @param message the error
     * @param cause the cause
     */
    public ConnoteaException(Message message, Throwable cause) {
        super(message.getMessage(), cause);
        apiMessage = message;
    }

    /**
     * Returns the apiMessage.
     * 
     * @return the apiMessage
     */
    public Message getApiMessage() {
        return apiMessage;
    }
}
